<script>
// #ifdef APP
import { initInterceptor } from '@/utils/permisionInterceptor';
import { APPUpdate } from '@/utils/appUpdate';
// #endif
import useCommonStore from '@/store/common';
// #ifdef APP
const aLiSDKModule = uni.requireNativePlugin('AliCloud-NirvanaPns');
// #endif
export default {
  onLaunch: function () {
    const system = uni.getSystemInfoSync();

    useCommonStore().setSystemInfo();
    // #ifdef APP
    initInterceptor();
    APPUpdate();
    this.handleAliOneClick(system);
    this.handleNetwork(system);
    // #endif
    console.log('App Launch', import.meta.env.VITE_APP_BASE_API);
  },
  onShow: function () {},
  onHide: function () {},
  methods: {
    handleAliOneClick: (system) => {
      console.log(system);
      if (system.osName === 'android') {
        //开启SDK日志打印
        aLiSDKModule.setLoggerEnable(true);
        aLiSDKModule.expandAuthPageCheckedScope(true);
        //禁用物理返回键
        //aLiSDKModule.closeAuthPageReturnBack(true);
        //开启区分界面返回及物理返回功能，自动控制后续返回事件
        aLiSDKModule.userControlAuthPageCancel();
        //是否跟随系统深色模式
        aLiSDKModule.setAuthPageUseDayLight(false);
        aLiSDKModule.setAuthSDKInfo(
          '8J87J74utQEPjNTGv5sikebnil2b/sGVbZkn8cmaoICO47FplldBmvLshLX2125RMeIN2CxvVz2y/pN5QPpB4FGDyil63kWLJ8+djFG7o9NKEETsd/ZiTAmljx+VkaUNx6OMi/WrhvrGT1KhsgzGT26CEJb1Gx2dSc09HW1TqP07o0DZ84HGRkaRGnj1QYlZS2cUYqjc7SzJ+CvlEJzR1n2tXugRdbIlnIuXAk6A8aAn91xa/6kRsHnwdxHKq1G5YWEeZYYMiy0755cAW5Nqw7wbJK/X6MXUIUC7aWV6+/E='
        );
      } else if (system.osName === 'ios') {
        aLiSDKModule.setAuthSDKInfo(
          'zmm3JoZVq1EkrvoKeGFAPmW9iKUMak9u1OuqEq6+P02Er9ig3UmCBiEqyK0UQDjfwznaRJcRSSrbrSiBicRRPkQOQPlrulE6uW6RZJg8fXxx8zSlAMIebKBFzaq9dYFRd02D71vT4ORsAPN4dBF4CSBHn88HkDwu3Fz3voq0AwBMiNxpqAr5tBHrX5TKCuS6v5NwbWnHW1TN7UpeaCUtjM7aZmhtXnEitKo473DNPGdKdAQg2bNEpE5J42T7KuvOHvIHNVJGg7Q='
        );
      }
    },
    handleNetwork: (system) => {
      const bol = uni.getStorageSync('first_install');

      if (system.osName === 'ios' && !bol) {
        uni.getNetworkType({
          success: (res) => {
            if (res.networkType === 'none') {
              uni.setStorageSync('first_install', res.networkType);
              uni.showModal({
                title: '系统提示',
                content: '当前无网络连接，请授权网络后，再次重启应用',
                confirmText: '重启',
                success: (mo) => {
                  if (mo.confirm) {
                    plus.runtime.restart();
                  }
                }
              });
            }
          }
        });
      }
    }
  }
};
</script>

<style lang="scss">
@font-face {
  font-family: 'ChuangKeTieJinGangTi';
  src: url('https://mingtu-resources.oss-cn-shenzhen.aliyuncs.com/mtym-app-assets/CKTKingkong.ttf') format('truetype');
}
.ChuangKeTieJinGangTi {
  font-family: 'ChuangKeTieJinGangTi';
}
page {
  color: #1c213e;
  background-color: #f5f5f5;
}
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clamp1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clamp2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.input-placeholder {
  font-size: 28rpx;
  color: #adb0bd;
}
.textarea-placeholder {
  font-size: 28rpx;
  color: #adb0bd;
}
:deep(.uni-input-input) {
  font-size: 28rpx;
  color: #1c213e;
}
:deep(.uni-textarea-wrapper) {
  font-size: 28rpx;
  color: #1c213e;
}
:deep(.uv-form-item__body__right__message) {
  margin-left: 32rpx !important;
  padding-bottom: 6rpx;
}
:deep(.uv-tabs) {
  .uv-tabs__wrapper__nav__item__text {
    font-size: 28rpx !important;
  }
  .uv-badge {
    font-size: 24rpx !important;
  }
}
.uv-index-list {
  :deep(.uv-index-anchor) {
    background-color: #ffffff !important;
    .uv-index-anchor__text {
      font-size: 28rpx !important;
      color: #1c213e !important;
      font-weight: bold;
    }
  }
}
.reset-button {
  margin-left: 0;
  margin-right: 0;
}
.da-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24rpx;
  height: 24rpx;
  color: #bbb;

  &::after {
    margin-bottom: -2rpx;
    /* stylelint-disable-next-line font-family-no-missing-generic-family-keyword */
    font-family: 'da-dropdown-iconfont' !important;
    font-size: 24rpx;
    font-style: normal;
    content: '\e604';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  &.is-actived {
    ::after {
      content: '\e604';
    }

    color: #007bff;
    opacity: 1;
    transform: rotate(180deg);
  }
}
.uni-mask {
  z-index: 10000 !important;
}
.uni-toast {
  z-index: 10000 !important;
}
</style>
